using System;
using System.Collections.Generic;
using System.Text;
using NBusiness.Query;

namespace NBusiness.Data.Providers.SqlServer.Query
{
    public class SqlParameter : SqlEvaluatable, IParameter
    {
        #region Member fields and properties
        private string _name; 
        #endregion

        #region Constructors
        public SqlParameter() { }
        public SqlParameter(string name)
        {
            _name = name;
        }
        #endregion

        #region IParameter Members

        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        #endregion

        #region IRelationalElement Members

        public override string ToSql()
        {
            return ToSql(new SqlQueryContext());
        }
        public override string ToSql(IQueryContext context)
        {

            return (_name.StartsWith("@") ?
                _name :
                "@" + _name);
        }

        #endregion

        #region object overrides

        public override string ToString()
        {
            return ToSql();
        }
        #endregion
    }
}
